<!-- 跨项目调整 -->
<template>
    <div>
        <el-header v-if="workItemId" height="36px">
            <header-title :title="headerTitle" />
        </el-header>
        <!-- 项目基础信息 -->
        <ProjectBackInfo :prjDetail="prjDetail"></ProjectBackInfo>
        <ProjectPreInfo :prjDetail="prjDetail"></ProjectPreInfo>
        <MaterialInfo :prjDetail="prjDetail"></MaterialInfo>
        <AttachmentInfo :prjParams="attachmentObj" v-if="getData"></AttachmentInfo>
        <!-- 项目审批信息 -->
        <ProjectApprovalInfo :process-inst-id="Number(workDetail.processInstID)"/>
        <!-- 按钮提交流程 -->
        <ButtonProcess
            v-if="isShowType"
            ref="btnProcess"
            :status="status"
            :btnOption="btnOption"
            :prjDetail="prjDetail"
            :workFlowData="workDetail"
        />
    </div>
</template>

<script>
import HeaderTitle from '@/components/basic/HeaderTitle'
import ProjectApprovalInfo from '@/components/jn/JnTaskDetail'
import ButtonProcess from './components/ButtonProcess.vue'
import MaterialInfo from "@/views/adjustProject/components/materialInfo.vue";
import ProjectPreInfo from "@/views/adjustProject/components/projectPreInfo.vue";
import ProjectBackInfo from "@/views/adjustProject/components/projectBackInfo.vue";
import AttachmentInfo from "@/views/adjustProject/components/attachmentInfo.vue";
import { getWFWorkItemApi } from '@/api/acceptanceManagement/acceptanceMange'
import { getQueryObject } from '@/utils'
import {getBackActivities} from "@/api/workFlow";
import {queryAdjustPrjFlowInfo} from "@/api/adjustProject";
export default {
    name: 'AdjustProject',
    components: {
        MaterialInfo,
        ProjectPreInfo,
        ProjectBackInfo,
        ButtonProcess,
        ProjectApprovalInfo,
        AttachmentInfo,
        HeaderTitle
    },
    data() {
        return {
            // 顶部标题名字
            headerTitle: '',
            // 是否显示下一步 退回 按钮
            isShowType: true,
            status: false, //是否是换签发起
            getData:false,
            workDetail:{},
            prjDetail:{},
            bizSeq:'',
            workItemId:'',
            btnOption: [],
            attachmentObj:{}
        }
    },
    created() {
        const { workItemId, type ,status } = getQueryObject()
        this.status = status === '1'
        this.workItemId = workItemId
        // 已办done 代办todo 存在workItemId
        if ( type === 'done') {
            this.isShowType = false
        }
        this.getWFWorkItem()
    },
    methods: {
        // 页面初始化获取processInid 流程节点 以及浏览器地址数据
        async getWFWorkItem() {
            getWFWorkItemApi(this.workItemId).then((res)=>{
                if(+res.code === 200){
                    this.workDetail = res.data
                    this.bizSeq = res.data.bizObject?.bizSeq
                    this.getProjectInfo(res.data.bizObject?.bizSeq);
                    this.$set(this.attachmentObj, 'prjId', res.data.bizObject?.bizSeq)
                    this.$set(this.attachmentObj, 'prjStage', res.data.bizObject?.wfStage)
                    this.$set(this.attachmentObj, 'nodeId', res.data.bizObject?.nodeCode)
                    //判断是不是发起页面 调用接口和审核页面不一样
                    if(this.status === '1' || res.data.activityDefID === 'adjust_prj1'){
                        this.btnOption = ['save','doNext','delete', 'close']
                    }else{
                        this.btnOption = ['save','doNext', 'back', 'close']
                    }
                }
            })
        },
        async getProjectInfo(bizSeq){
            queryAdjustPrjFlowInfo(bizSeq).then((res)=>{
                if(+res.code === 200){
                    this.prjDetail = res.data
                    this.headerTitle=`${res.data.newPrjName}-跨项目调整-${this.workDetail.activityInstName}`
                    this.$set(this.attachmentObj, 'prjType', res.data.prjType)
                    this.$set(this.attachmentObj, 'processId', '')
                    this.$set(this.attachmentObj, 'buildModes', res.data.buildModes)
                    this.$set(this.attachmentObj, 'towerType', res.data.towerType)
                    this.$set(this.attachmentObj, 'roomType', res.data.roomType)
                    this.$set(this.attachmentObj, 'orgId', res.data.orgId)
                    this.getData=true
                }
            })
        },
    }
}
</script>
<style lang="scss" scoped></style>
